<!DOCTYPE html>
<html>
#{include file="header.html"}#
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">
  <div class="row">
    <div class="col-sm-12">
      <div class="ibox float-e-margins">
        <div class="ibox-content">
          <form class="form-horizontal" method="post" action="#">
            <input type="hidden" name="field_ext_id" value="#{$one.field_ext_id}#">
            <input type="hidden" name="main_table" value="#{$one.main_table}#">
            <input type="hidden" name="ext_table" value="#{$one.ext_table}#">
            <div class="form-group">
              <label class="col-sm-2 control-label">表单提示文字</label>
              <div class="col-sm-8">
                <input name="show_name" class="form-control" type="text" value="#{$one.show_name}#" required/>
                <span class="help-block m-b-none">发布内容时显示的提示文字</span> </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">字段名称</label>
              <div class="col-sm-8">
                <input name="field_name" class="form-control" type="text" value="#{$one.field_name}#" readonly/>
                <span class="help-block m-b-none">只能用英文字母或数字，数据表的真实字段名</span> </div>
            </div>
            <div class="form-group text-left">
              <label class="col-sm-2 control-label">数据类型</label>
              <div class="col-sm-8">
                <select data-placeholder="选择数据类型..." name="field_type" class="chosen-select type-chosen-select" style="width: 200px;" tabindex="2">
                  
								  #{foreach from=$type key=k item=v}#	  
						
                  <option value="#{$k}#" hassubinfo="true">#{$v.name}#</option>
                  
								  #{/foreach}#

					  
                </select>
              </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">默认值</label>
              <div class="col-sm-8">
                <textarea name="default" class="form-control">#{$one.default}#</textarea>
                <span class="help-block m-b-none">如果定义数据类型为select、radio、checkbox时，此处填写被选择的项目(用“,”分开，如“男,女,人妖”)。</span> </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">最大值</label>
              <div class="col-sm-8">
                <input name="maxlength" class="form-control" type="text" value="#{$one.maxlength}#" required/>
                <span class="help-block m-b-none">文本数据必须填写，大于255为text类型</span> </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">排序</label>
              <div class="col-sm-8">
                <input name="sort" class="form-control" type="text" value="#{$one.sort}#" required/>
                <span class="help-block m-b-none"></span> </div>
            </div>
            <div class="form-group">
              <label class="col-sm-2 control-label">是否启用</label>
              <div class="col-sm-8">
                <div class="checkbox i-checks">
                  <input type="checkbox" name="visible" value="1" #{if $one.visible eq '1'}# checked #{/if}#/>
                </div>
              </div>
            </div>
			  <div class="form-group">
              <label class="col-sm-2 control-label">是否验证</label>
              <div class="col-sm-8">
                <div class="checkbox i-checks">
                  <input type="checkbox" name="is_must" value="1" #{if $one.is_must eq '1'}# checked #{/if}#/>
					<span class="help-block m-b-none">注：选择勾选表示该项为必填项</span>
                </div>
              </div>
            </div>
            <div class="form-group">
              <div class="col-sm-offset-2 col-sm-8">
                <button class="btn  btn-w-m btn-info save-form" type="button">保存数据</button>
              </div>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 自定义js --> 
<script src="#{$smarty.const.APP}#/View/template/js/content.js?v=1.0.0"></script> 
<script>
$(document).ready(function () {
	$('.i-checks').iCheck({
		checkboxClass: 'icheckbox_square-green',
		radioClass: 'iradio_square-green',
	});
	$('.chosen-select').chosen({search_contains: true});
	$(".type-chosen-select").val("#{$one.field_type}#").trigger("chosen:updated");
	//数据保存
	$("body").on("click", ".save-form", function() {
		FormData=$("form").serialize();
		$.ajax({
			type: "POST",
			url: "#{$smarty.const.ACT}#/crm/CstFieldExt/cst_field_ext_modify/",
			data:FormData,
			dataType:"json",
			success: function(data){
				if(data.statusCode=='200'){
					layer.msg('操作成功', {icon: 1}); 		
				}else{
					layer.msg(data.message, {icon: 5});
				}
			},    
			complete: function() {   
				setTimeout(function(){
					//关闭窗口
					var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
					parent.layer.close(index);
				 },800);
   		  },
		});		
	});
	
});
</script>
</body>
</html>